//
//  FGServiceCollectionCell.swift
//  FlagApp
//
//  Created by momo on 2020/12/31.
//

import UIKit

class FGServiceCollectionCell: UICollectionViewCell {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        contentView.addSubview(iconImg)
        contentView.addSubview(titLab)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        iconImg.snp_updateConstraints { (make) in
            make.width.height.equalTo(30)
            make.centerX.equalToSuperview()
            make.top.equalTo(10)
        }
        
        titLab.snp_updateConstraints { (make) in
            make.top.equalTo(iconImg.snp_bottom).offset(10)
            make.centerX.equalToSuperview()
            make.width.equalToSuperview()
        }
    }
    
    var cellModel: FGMyCenterModel! {
        willSet(newValue){
            self.cellModel = newValue
            
        }
        
        didSet{
            self.titLab.text = self.cellModel.titleStr
            self.iconImg.image = UIImage(named: self.cellModel.imageName!)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy var iconImg: UIImageView = {
        () -> UIImageView in
        let icon = UIImageView()
        icon.backgroundColor = UIColor.red
        return icon
    }()
    
    lazy var titLab: UILabel = {
        () -> UILabel in
        let lab = UILabel()
        lab.textColor = UIColor.hex(hexString: "#333333")
        lab.font = UIFont.systemFont(ofSize: 14)
        lab.textAlignment = .center
        return lab
    }()
    
}
